import ReactDOM from 'react-dom/client';
import { RouterProvider, createBrowserRouter, Link, Outlet } from 'react-router-dom';
import { Index } from './page/index/Index';
import { ErrorPage } from './page/error_page/ErrorPage';
import { UserManage } from './page/user_manage/UserManage';
import { Login } from './page/login/Login';
import './common/index.css';
import { Menu } from './page/menu/Menu';
import { ModifyMenu } from './page/modify_menu/ModifyMenu';
import { InfoModify } from './page/info_modify/InfoModify';
import { PasswordModify } from './page/password_modify/PasswordModify';
import { MeetingRoomManage } from './page/meeting_room_manage/MeetingRoomManage';
import { BookingManage } from './page/book_manage/BookingManage';
import { Statistics } from './page/statistics/Statistics';

const routes = [
  {
    path: "/",
    element: <Index></Index>,
    errorElement: <ErrorPage />,
    children: [

      {
        path: "/",
        element: <Menu></Menu>,
        children: [
          //3级路由
          {
            path: '/',
            element: <MeetingRoomManage />
          },
          {
            path: 'user_manage',
            element: <UserManage />
          },
          {
            path: 'meeting_room_manage',
            element: <MeetingRoomManage />
          },
          {
            path: 'booking_manage',
            element: <BookingManage />
          },
          {
            path: 'statistics',
            element: <Statistics />
          }

        ]
      },

      {
        path: "/user",
        element: <ModifyMenu></ModifyMenu>,
        children: [
          {
            path: 'info_modify',
            element: <InfoModify />
          },
          {
            path: 'password_modify',
            element: <PasswordModify />
          },
        ]
      },

    ]
  },
  {
    path: "login",
    element: <Login />,
  }
];

export const router = createBrowserRouter(routes);

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);

root.render(<RouterProvider router={router} />);